package cn.iocoder.idata.module.idata.dal.mysql.template;

import java.util.*;

import cn.iocoder.idata.framework.common.pojo.PageResult;
import cn.iocoder.idata.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.idata.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.idata.module.idata.dal.dataobject.template.TemplateDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.idata.module.idata.controller.admin.template.vo.*;

/**
 * 标注模板管理 Mapper
 *
 * @author wanghaiyang
 */
@Mapper
public interface TemplateMapper extends BaseMapperX<TemplateDO> {

    default PageResult<TemplateDO> selectPage(TemplatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TemplateDO>()
                .likeIfPresent(TemplateDO::getName, reqVO.getName())
                .eqIfPresent(TemplateDO::getAnnotationType, reqVO.getAnnotationType())
                .eqIfPresent(TemplateDO::getDataType, reqVO.getDataType())
                .likeIfPresent(TemplateDO::getAnnotationObject, reqVO.getAnnotationObject())
                .orderByDesc(TemplateDO::getId));
    }

    default List<TemplateDO> selectList(TemplateExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TemplateDO>()
                .likeIfPresent(TemplateDO::getName, reqVO.getName())
                .eqIfPresent(TemplateDO::getAnnotationType, reqVO.getAnnotationType())
                .eqIfPresent(TemplateDO::getDataType, reqVO.getDataType())
                .likeIfPresent(TemplateDO::getAnnotationObject, reqVO.getAnnotationObject())
                .orderByDesc(TemplateDO::getId));
    }

}
